package cn.stronglink.asset.terminal.jd.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;

import cn.stronglink.asset.model.PresetDetail;
import cn.stronglink.asset.terminal.jd.service.JDAPIService;
import cn.stronglink.asset.terminal.jd.vo.JDResultData.DetailData;
import cn.stronglink.asset.terminal.unicom.param.DoCheckParam;
import cn.stronglink.asset.terminal.unicom.service.ApiService;
import cn.stronglink.suite.core.base.AbstractController;

@Controller
@RequestMapping(value = "jd")
public class JDAPIController extends AbstractController{
	
	@Autowired
	private ApiService apiService;
	@Autowired
	private JDAPIService jdapiService ;
	/**
	 * 手持端  查询需要验收的列表  
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param params
	 * @return
	 */
	@RequestMapping(value = "qryCheckList")
	public ResponseEntity<ModelMap> qryCheckBeforeList(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response) {	
		List<PresetDetail> data = apiService.qryTerminalCheckList();
		System.out.println(JSON.toJSON(data)+"*************验收单********** ");
		return setSuccessModelMap(modelMap, data);
	}	
	
	/**
	 * 手持 验收
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param asset
	 * @return
	 */
	@RequestMapping(value = "doCheckTerminal")
	public ResponseEntity<ModelMap> doCheckTerminal(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody List<DoCheckParam> assetList) {
		System.out.println(JSON.toJSON(assetList)+"************验收数据数据**************");
		DetailData data = jdapiService.CheckTerminal(assetList);
		return setSuccessModelMap(modelMap, data);
	}	
	
}
